package com.by.yz.mypersonal;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.by.yz.R;
import com.by.yz.activity.PersonalEditActivity;
import com.by.yz.activity.base.BaseActivity;
import com.by.yz.common.MFGT;

/**
 * Created by 123 on 2016/10/7.
 */
public class PersonalContractSetActivity extends BaseActivity  implements View.OnClickListener {

    private RelativeLayout info;
    private RelativeLayout blacklist;
    private Button contract;
    private Button message;
    private ImageView openNotification;
    private ImageView closeNotification;
    private ImageView openVoice;
    private ImageView closeVoice;
    private ImageView openVibrate;
    private ImageView closeVibrate;

    private View notification;
    private View voice;
    private View vibrate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.personal_contract_set);
        setToolbarTitle("设置");

        initView();
        initDatas();

    }

    private void initDatas() {

    }

    private void initView() {

        info = (RelativeLayout) findViewById(R.id.layout_info);
        info.setOnClickListener(this);

        blacklist = (RelativeLayout) findViewById(R.id.layout_blacklist);
        blacklist.setOnClickListener(this);

//        contract = (Button) findViewById(R.id.btn_contract);
//        contract.setOnClickListener(this);
//
//        message = (Button) findViewById(R.id.btn_message);
//        message.setOnClickListener(this);

        notification = findViewById(R.id.rl_switch_notification);
        notification.setOnClickListener(this);

        voice = findViewById(R.id.rl_switch_voice);
        voice.setOnClickListener(this);

        vibrate = findViewById(R.id.rl_switch_vibrate);
        vibrate.setOnClickListener(this);

        openNotification = (ImageView) findViewById(R.id.iv_open_notification);

        closeNotification = (ImageView) findViewById(R.id.iv_close_notification);

        openVoice = (ImageView) findViewById(R.id.iv_open_voice);

        closeVoice = (ImageView) findViewById(R.id.iv_close_voice);

        openVibrate = (ImageView) findViewById(R.id.iv_open_vibrate);

        closeVibrate = (ImageView) findViewById(R.id.iv_close_vibrate);
    }

    @Override
    public void onClick(View v) {

        switch (v.getId()){

            case R.id.layout_info:
                MFGT.startActivity(this, PersonalEditActivity.class);
                break;

            case R.id.layout_blacklist:
                MFGT.startActivity(this, PersonalBlacklistActivity.class);
                break;

//            case R.id.btn_contract:
//                MFGT.startActivity(this, PersonalContractActivity.class);
//                this.finish();
//                break;
//
//            case R.id.btn_message:
//                MFGT.startActivity(this, PersonalContractChatActivity.class);
//                this.finish();
//                break;

            case R.id.rl_switch_notification:
                if(openNotification.getVisibility() == View.VISIBLE){
                    openNotification.setVisibility(View.GONE);
                    closeNotification.setVisibility(View.VISIBLE);
                    voice.setVisibility(View.GONE);
                    vibrate.setVisibility(View.GONE);
                }else{
                    openNotification.setVisibility(View.VISIBLE);
                    closeNotification.setVisibility(View.GONE);
                    voice.setVisibility(View.VISIBLE);
                    vibrate.setVisibility(View.VISIBLE);
                }
                break;

            case R.id.rl_switch_voice:
                if(openVoice.getVisibility() == View.VISIBLE){
                    openVoice.setVisibility(View.GONE);
                    closeVoice.setVisibility(View.VISIBLE);
                }else{
                    openVoice.setVisibility(View.VISIBLE);
                    closeVoice.setVisibility(View.GONE);
                }
                break;

            case R.id.rl_switch_vibrate:
                if(openVibrate.getVisibility() == View.VISIBLE) {
                    openVibrate.setVisibility(View.GONE);
                    closeVibrate.setVisibility(View.VISIBLE);
                }else{
                    openVibrate.setVisibility(View.VISIBLE);
                    closeVibrate.setVisibility(View.GONE);
                }
                break;

        }
    }

//    @Override
//    public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); return true;
//        getMenuInflater().inflate(R.menu.mm, menu);
//        return true;
//    }

//    @Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//        switch (item.getItemId()) {
//           case android.R.id.home:
//                Toast.makeText(this, "home", Toast.LENGTH_SHORT).show();
//                return true;
//            case R.id.m1:
//                Toast.makeText(this, "m1", Toast.LENGTH_SHORT).show();
//                break;
//            case R.id.m2:
//                Toast.makeText(this, "m2", Toast.LENGTH_SHORT).show();
//                break;
//
//        }
//        return super.onOptionsItemSelected(item);
//    }
}
